// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.iso.sprite;

import zombie.core.Core;
import zombie.core.SpriteRenderer;
import zombie.core.textures.Texture;
import zombie.iso.IsoUtils;
import zombie.network.GameServer;

public final class CorpseFlies {
    private static Texture TEXTURE;
    private static final int FRAME_WIDTH = 128;
    private static final int FRAME_HEIGHT = 128;
    private static final int COLUMNS = 8;
    private static final int ROWS = 7;
    private static final int NUM_FRAMES = 56;
    private static float COUNTER = 0.0F;
    private static int FRAME = 0;

    public static void render(int squareX, int squareY, int squareZ) {
        if (TEXTURE == null) {
            TEXTURE = Texture.getSharedTexture("media/textures/CorpseFlies.png");
        }

        if (TEXTURE != null && TEXTURE.isReady()) {
            int int0 = (FRAME + squareX + squareY) % 56;
            int int1 = int0 % 8;
            int int2 = int0 / 8;
            float float0 = (float)(int1 * 128) / (float)TEXTURE.getWidth();
            float float1 = (float)(int2 * 128) / (float)TEXTURE.getHeight();
            float float2 = (float)((int1 + 1) * 128) / (float)TEXTURE.getWidth();
            float float3 = (float)((int2 + 1) * 128) / (float)TEXTURE.getHeight();
            float float4 = IsoUtils.XToScreen((float)squareX + 0.5F, (float)squareY + 0.5F, (float)squareZ, 0) + IsoSprite.globalOffsetX;
            float float5 = IsoUtils.YToScreen((float)squareX + 0.5F, (float)squareY + 0.5F, (float)squareZ, 0) + IsoSprite.globalOffsetY;
            byte _byte = 64;
            int int3 = _byte * Core.TileScale;
            float4 -= (float)(int3 / 2);
            float5 -= (float)(int3 + 16 * Core.TileScale);
            if (Core.bDebug) {
            }

            SpriteRenderer.instance
                .render(
                    TEXTURE, float4, float5, (float)int3, (float)int3, 1.0F, 1.0F, 1.0F, 1.0F, float0, float1, float2, float1, float2, float3, float0, float3
                );
        }
    }

    public static void update() {
        if (!GameServer.bServer) {
            COUNTER = COUNTER + zombie.GameTime.getInstance().getRealworldSecondsSinceLastUpdate() * 1000.0F;
            float _float = 20.0F;
            if (COUNTER > 1000.0F / _float) {
                COUNTER %= 1000.0F / _float;
                FRAME++;
                FRAME %= 56;
            }
        }
    }

    public static void Reset() {
        TEXTURE = null;
    }
}
